<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>创建自定义元素</title>
</head>
<body>
  <x-foo>I'm inside a nonsense element.</x-foo>
  <script>
    class FooElement extends HTMLElement {}
    customElements.define('x-foo', FooElement);
    console.log(document.querySelector('x-foo') instanceof FooElement);  // true
  </script>
</body>
</html>